import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class Test3 {
    public static void main(String[] args) {
        Set<String> set = new HashSet<>();
        set.add("刘备");
        set.add("关羽");
        set.add("张飞");
        set.add("刘备");
        set.add("张飞");

        System.out.println(set.size());//集合大小
        System.out.println("------------------------");
        Iterator<String> it = set.iterator();//迭代器方法
        while (it.hasNext()) {
            String next = it.next();
            System.out.println(next);
        }
        System.out.println("------------------------");

        for (String s : set) {//for增强方法
            System.out.println(s);
        }
    }
}